{extend name="public:adminbase" /}

{block name="content"}


<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-header">
          <h4>登录日志</h4>
        </div>
        <div class="card-toolbar clearfix">


        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>编号</th>
                  <th>昵称</th>
                  <th>创建</th>
                  <th>url</th>
                  <th>ip</th>
                </tr>
              </thead>
              <tbody>
                {foreach $list as $v}
                <tr>
                  <td>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" name="ids[]" value="{$v.id}"><span></span>
                    </label>
                  </td>
                  <td>{$v.id}</td>
                  <td>{$v.nickname}</td>
                  <td>{$v.create_time}</td>
                  <td>{$v.url}</td>
                  <td>{$v.ip}</td>
                </tr>
                {/foreach}

              </tbody>
            </table>
          </div>
          {$list|raw}
 
        </div>
      </div>
    </div>
    
  </div>
  
</div>
{include file="public/afooter"}
<script>
//  新增
  function AddCate(obj) {
    var url = $(obj).attr('href');
    layer.open({
      title:"新增分类",
      type: 2,
      area: ['500px', '450px'],
      fixed: false, //不固定
      maxmin: true,
      content: url
    });
  }

  //更新sitemap
$('#sitemap').click(function(){
  var url="{:url('AdminArticle/sitemap')}";
  $.post(url,{ids:1},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),3000);
    } else {
      error(e.msg);
    }
  })
})

  //推送到百度站长平台
$('#dosubmit').click(function(){
  var checkID = [];//定义一个空数组
  $("input[name='ids[]']:checked").each(function(i){
    //把所有被选中的复选框的值存入数组
    checkID[i] =$(this).val();
  });
//  console.log(checkID);
  var url="{:url('AdminArticle/push_to_baidu_all')}";
  $.post(url,{ids:checkID},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),3000);
    } else {
      error(e.msg);
    }
  })
})
//修改
//  function edit(obj) {
//    var url = $(obj).attr('href');
//    layer.open({
//      title:"修改",
//      type: 2,
//      area: ['500px', '450px'],
//      fixed: false, //不固定
//      maxmin: true,
//      content: url
//    });
//  }
//  删除
  function del(id) {
    layer.confirm('您确定要删除吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
      var url = "{:url('delete')}"
      $.post(url,{id:id},function (e) {
        if(e.code != 200){
          error(e.msg);
        }else {
          success(e.msg);
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 1000);
          window.parent.location.reload();
        }
      })
    }, function(){
      layer.msg('已取消');
    });
  }

  //修改置顶状态
  function change_top(id) {
    var url ="{:url('change_top')}";
    $.post(url,{id:id},function (e) {
      if(e.code ==200){
        success(e.msg);
        setTimeout(location.reload(),1000);
      } else {
        error(e.msg);
      }
    })
  }
  //修改推荐状态

function change_recommend(id) {
  var url ="{:url('change_recommend')}";
  $.post(url,{id:id},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),1000);
    } else {
      error(e.msg);
    }
  })
}

function sync_baijiahao(id) {
    var url ="{:url('sync_baijiahao')}";
    $.post(url,{id:id},function (e) {
        if(e.code ==200){
            success(e.msg);
            setTimeout(location.reload(),1000);
        } else {
            error(e.msg);
        }
    })
}

function del_all() {
    var checkID = [];//定义一个空数组
    $("input[name='ids[]']:checked").each(function(i){
        //把所有被选中的复选框的值存入数组
        checkID[i] =$(this).val();
    });
    var url="{:url('del_all')}";

    layer.confirm('您确定要删除选中项吗，删除后不可恢复哦？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        var url = "{:url('del_all')}"
        $.post(url,{ids:checkID},function (e) {
            if(e.code ==200){
                success(e.msg);
                setTimeout(location.reload(),3000);
            } else {
                error(e.msg);
            }
        })
    }, function(){
        layer.msg('已取消');
    });



}
</script>

{/block}